﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Charities.ModelViews
{
    class GrantComparer : IEqualityComparer<GrantView >
{
    public bool Equals(GrantView  x, GrantView y)
    {
        //Check whether the compared objects reference the same data.
        if (Object.ReferenceEquals(x, y)) return true;

        //Check whether any of the compared objects is null.
        if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
            return false;

        return x.name == y.name;
    }

    // If Equals() returns true for a pair of objects 
    // then GetHashCode() must return the same value for these objects.

    public int GetHashCode(GrantView  grant)
    {
        //Check whether the object is null
        if (Object.ReferenceEquals(grant, null)) return 0;

        return grant.name == null ? 0 : grant.name.GetHashCode();
    }
}
}
